package com.example.mymarsphotos.ui

import com.example.mymarsphotos.fake.FakeDataSource
import com.example.mymarsphotos.fake.FakeNetworkMarsPhotosRepository
import com.example.mymarsphotos.rules.TestDispatcherRule
import com.example.mymarsphotos.ui.screen.MarsUiState
import com.example.mymarsphotos.ui.screen.MarsViewModel
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test

class MarsViewModelTest {
    // replace the main dispatcher with a test dispatcher before a test begins to execute
    @get:Rule
    val testDispatcher = TestDispatcherRule()

    @Test
    fun marsViewModel_getMarsPhotos_verifyMarsUiStateSuccess() =
        runTest {
            val marsViewModel = MarsViewModel(FakeNetworkMarsPhotosRepository())
            assertEquals(
                MarsUiState.Success(FakeDataSource.photosList),
                marsViewModel.marsUiState
            )
        }
}